3.9.72 \(\int (a+b \sec (c+d x))^2 (A+B \sec (c+d x)+C \sec ^2(c+d x)) \, dx\) [872]

3.9.72.1 Optimal result
3.9.72.2 Mathematica [A] (verified)
3.9.72.3 Rubi [A] (verified)
3.9.72.4 Maple [A] (verified)
3.9.72.5 Fricas [A] (verification not implemented)
3.9.72.6 Sympy [F]
3.9.72.7 Maxima [A] (verification not implemented)
3.9.72.8 Giac [B] (verification not implemented)
3.9.72.9 Mupad [B] (verification not implemented)

3.9.72.1 Optimal result

Integrand size = 33, antiderivative size = 134 \[ \int (a+b \sec (c+d x))^2 \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=a^2 A x+\frac {\left (2 a^2 B+b^2 B+2 a b (2 A+C)\right ) \text {arctanh}(\sin (c+d x))}{2 d}+\frac {\left (3 A b^2+6 a b B+2 a^2 C+2 b^2 C\right ) \tan (c+d x)}{3 d}+\frac {b (3 b B+2 a C) \sec (c+d x) \tan (c+d x)}{6 d}+\frac {C (a+b \sec (c+d x))^2 \tan (c+d x)}{3 d} \]

output
a^2*A*x+1/2*(2*B*a^2+B*b^2+2*a*b*(2*A+C))*arctanh(sin(d*x+c))/d+1/3*(3*A*b 
^2+6*B*a*b+2*C*a^2+2*C*b^2)*tan(d*x+c)/d+1/6*b*(3*B*b+2*C*a)*sec(d*x+c)*ta 
n(d*x+c)/d+1/3*C*(a+b*sec(d*x+c))^2*tan(d*x+c)/d
 
3.9.72.2 Mathematica [A] (verified)

Time = 1.74 (sec) , antiderivative size = 108, normalized size of antiderivative = 0.81 \[ \int (a+b \sec (c+d x))^2 \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=\frac {6 a^2 A d x+3 \left (2 a^2 B+b^2 B+2 a b (2 A+C)\right ) \text {arctanh}(\sin (c+d x))+3 \left (2 \left (A b^2+2 a b B+a^2 C+b^2 C\right )+b (b B+2 a C) \sec (c+d x)\right ) \tan (c+d x)+2 b^2 C \tan ^3(c+d x)}{6 d} \]

input
Integrate[(a + b*Sec[c + d*x])^2*(A + B*Sec[c + d*x] + C*Sec[c + d*x]^2),x 
]
 
output
(6*a^2*A*d*x + 3*(2*a^2*B + b^2*B + 2*a*b*(2*A + C))*ArcTanh[Sin[c + d*x]] 
 + 3*(2*(A*b^2 + 2*a*b*B + a^2*C + b^2*C) + b*(b*B + 2*a*C)*Sec[c + d*x])* 
Tan[c + d*x] + 2*b^2*C*Tan[c + d*x]^3)/(6*d)
 
3.9.72.3 Rubi [A] (verified)

Time = 0.47 (sec) , antiderivative size = 141, normalized size of antiderivative = 1.05, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.152, Rules used = {3042, 4544, 3042, 4536, 2009}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int (a+b \sec (c+d x))^2 \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \left (a+b \csc \left (c+d x+\frac {\pi }{2}\right )\right )^2 \left (A+B \csc \left (c+d x+\frac {\pi }{2}\right )+C \csc \left (c+d x+\frac {\pi }{2}\right )^2\right )dx\)

\(\Big \downarrow \) 4544

\(\displaystyle \frac {1}{3} \int (a+b \sec (c+d x)) \left ((3 b B+2 a C) \sec ^2(c+d x)+(3 A b+2 C b+3 a B) \sec (c+d x)+3 a A\right )dx+\frac {C \tan (c+d x) (a+b \sec (c+d x))^2}{3 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {1}{3} \int \left (a+b \csc \left (c+d x+\frac {\pi }{2}\right )\right ) \left ((3 b B+2 a C) \csc \left (c+d x+\frac {\pi }{2}\right )^2+(3 A b+2 C b+3 a B) \csc \left (c+d x+\frac {\pi }{2}\right )+3 a A\right )dx+\frac {C \tan (c+d x) (a+b \sec (c+d x))^2}{3 d}\)

\(\Big \downarrow \) 4536

\(\displaystyle \frac {1}{3} \left (\frac {1}{2} \int \left (6 A a^2+2 \left (2 C a^2+6 b B a+3 A b^2+2 b^2 C\right ) \sec ^2(c+d x)+3 \left (2 B a^2+2 b (2 A+C) a+b^2 B\right ) \sec (c+d x)\right )dx+\frac {b (2 a C+3 b B) \tan (c+d x) \sec (c+d x)}{2 d}\right )+\frac {C \tan (c+d x) (a+b \sec (c+d x))^2}{3 d}\)

\(\Big \downarrow \) 2009

\(\displaystyle \frac {1}{3} \left (\frac {1}{2} \left (\frac {3 \left (2 a^2 B+2 a b (2 A+C)+b^2 B\right ) \text {arctanh}(\sin (c+d x))}{d}+\frac {2 \tan (c+d x) \left (2 a^2 C+6 a b B+3 A b^2+2 b^2 C\right )}{d}+6 a^2 A x\right )+\frac {b (2 a C+3 b B) \tan (c+d x) \sec (c+d x)}{2 d}\right )+\frac {C \tan (c+d x) (a+b \sec (c+d x))^2}{3 d}\)

input
Int[(a + b*Sec[c + d*x])^2*(A + B*Sec[c + d*x] + C*Sec[c + d*x]^2),x]
 
output
(C*(a + b*Sec[c + d*x])^2*Tan[c + d*x])/(3*d) + ((b*(3*b*B + 2*a*C)*Sec[c 
+ d*x]*Tan[c + d*x])/(2*d) + (6*a^2*A*x + (3*(2*a^2*B + b^2*B + 2*a*b*(2*A 
 + C))*ArcTanh[Sin[c + d*x]])/d + (2*(3*A*b^2 + 6*a*b*B + 2*a^2*C + 2*b^2* 
C)*Tan[c + d*x])/d)/2)/3
 

3.9.72.3.1 Defintions of rubi rules used

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4536
Int[((A_.) + csc[(e_.) + (f_.)*(x_)]*(B_.) + csc[(e_.) + (f_.)*(x_)]^2*(C_. 
))*(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_)), x_Symbol] :> Simp[(-b)*C*Csc[e + 
 f*x]*(Cot[e + f*x]/(2*f)), x] + Simp[1/2   Int[Simp[2*A*a + (2*B*a + b*(2* 
A + C))*Csc[e + f*x] + 2*(a*C + B*b)*Csc[e + f*x]^2, x], x], x] /; FreeQ[{a 
, b, e, f, A, B, C}, x]
 

rule 4544
Int[((A_.) + csc[(e_.) + (f_.)*(x_)]*(B_.) + csc[(e_.) + (f_.)*(x_)]^2*(C_. 
))*(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_))^(m_.), x_Symbol] :> Simp[(-C)*Cot 
[e + f*x]*((a + b*Csc[e + f*x])^m/(f*(m + 1))), x] + Simp[1/(m + 1)   Int[( 
a + b*Csc[e + f*x])^(m - 1)*Simp[a*A*(m + 1) + ((A*b + a*B)*(m + 1) + b*C*m 
)*Csc[e + f*x] + (b*B*(m + 1) + a*C*m)*Csc[e + f*x]^2, x], x], x] /; FreeQ[ 
{a, b, e, f, A, B, C}, x] && NeQ[a^2 - b^2, 0] && IGtQ[2*m, 0]
 
3.9.72.4 Maple [A] (verified)

Time = 0.92 (sec) , antiderivative size = 136, normalized size of antiderivative = 1.01

method result size
parts \(a^{2} A x +\frac {\left (2 a A b +B \,a^{2}\right ) \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{d}+\frac {\left (B \,b^{2}+2 C a b \right ) \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )}{d}+\frac {\left (A \,b^{2}+2 B a b +C \,a^{2}\right ) \tan \left (d x +c \right )}{d}-\frac {C \,b^{2} \left (-\frac {2}{3}-\frac {\sec \left (d x +c \right )^{2}}{3}\right ) \tan \left (d x +c \right )}{d}\) \(136\)
derivativedivides \(\frac {a^{2} A \left (d x +c \right )+B \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+C \,a^{2} \tan \left (d x +c \right )+2 a A b \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 B \tan \left (d x +c \right ) a b +2 C a b \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+A \tan \left (d x +c \right ) b^{2}+B \,b^{2} \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )-C \,b^{2} \left (-\frac {2}{3}-\frac {\sec \left (d x +c \right )^{2}}{3}\right ) \tan \left (d x +c \right )}{d}\) \(183\)
default \(\frac {a^{2} A \left (d x +c \right )+B \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+C \,a^{2} \tan \left (d x +c \right )+2 a A b \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 B \tan \left (d x +c \right ) a b +2 C a b \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+A \tan \left (d x +c \right ) b^{2}+B \,b^{2} \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )-C \,b^{2} \left (-\frac {2}{3}-\frac {\sec \left (d x +c \right )^{2}}{3}\right ) \tan \left (d x +c \right )}{d}\) \(183\)
parallelrisch \(\frac {-6 \left (\cos \left (3 d x +3 c \right )+3 \cos \left (d x +c \right )\right ) \left (\frac {B \,b^{2}}{4}+a \left (A +\frac {C}{2}\right ) b +\frac {B \,a^{2}}{2}\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )+6 \left (\cos \left (3 d x +3 c \right )+3 \cos \left (d x +c \right )\right ) \left (\frac {B \,b^{2}}{4}+a \left (A +\frac {C}{2}\right ) b +\frac {B \,a^{2}}{2}\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )+3 a^{2} A x d \cos \left (3 d x +3 c \right )+\left (b^{2} \left (3 A +2 C \right )+6 B a b +3 C \,a^{2}\right ) \sin \left (3 d x +3 c \right )+3 \left (B \,b^{2}+2 C a b \right ) \sin \left (2 d x +2 c \right )+9 a^{2} A x d \cos \left (d x +c \right )+3 \left (b^{2} \left (A +2 C \right )+2 B a b +C \,a^{2}\right ) \sin \left (d x +c \right )}{3 d \left (\cos \left (3 d x +3 c \right )+3 \cos \left (d x +c \right )\right )}\) \(247\)
norman \(\frac {a^{2} A x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{6}-a^{2} A x +\frac {4 \left (3 A \,b^{2}+6 B a b +3 C \,a^{2}+C \,b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3}}{3 d}-\frac {\left (2 A \,b^{2}+4 B a b -B \,b^{2}+2 C \,a^{2}-2 C a b +2 C \,b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{5}}{d}-\frac {\left (2 A \,b^{2}+4 B a b +B \,b^{2}+2 C \,a^{2}+2 C a b +2 C \,b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d}+3 a^{2} A x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-3 a^{2} A x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{4}}{\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1\right )^{3}}-\frac {\left (4 a A b +2 B \,a^{2}+B \,b^{2}+2 C a b \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{2 d}+\frac {\left (4 a A b +2 B \,a^{2}+B \,b^{2}+2 C a b \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{2 d}\) \(295\)
risch \(a^{2} A x -\frac {i \left (3 B \,b^{2} {\mathrm e}^{5 i \left (d x +c \right )}+6 C a b \,{\mathrm e}^{5 i \left (d x +c \right )}-6 A \,b^{2} {\mathrm e}^{4 i \left (d x +c \right )}-12 B a b \,{\mathrm e}^{4 i \left (d x +c \right )}-6 C \,a^{2} {\mathrm e}^{4 i \left (d x +c \right )}-12 A \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}-24 B a b \,{\mathrm e}^{2 i \left (d x +c \right )}-12 C \,a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-12 C \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}-3 B \,b^{2} {\mathrm e}^{i \left (d x +c \right )}-6 C b a \,{\mathrm e}^{i \left (d x +c \right )}-6 A \,b^{2}-12 B a b -6 C \,a^{2}-4 C \,b^{2}\right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{3}}-\frac {2 \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) a A b}{d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) B \,a^{2}}{d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) B \,b^{2}}{2 d}-\frac {a b \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) C}{d}+\frac {2 \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) a A b}{d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) B \,a^{2}}{d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) B \,b^{2}}{2 d}+\frac {a b \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) C}{d}\) \(382\)

input
int((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)+C*sec(d*x+c)^2),x,method=_RETURNVER 
BOSE)
 
output
a^2*A*x+(2*A*a*b+B*a^2)/d*ln(sec(d*x+c)+tan(d*x+c))+(B*b^2+2*C*a*b)/d*(1/2 
*sec(d*x+c)*tan(d*x+c)+1/2*ln(sec(d*x+c)+tan(d*x+c)))+(A*b^2+2*B*a*b+C*a^2 
)/d*tan(d*x+c)-C*b^2/d*(-2/3-1/3*sec(d*x+c)^2)*tan(d*x+c)
 
3.9.72.5 Fricas [A] (verification not implemented)

Time = 0.28 (sec) , antiderivative size = 179, normalized size of antiderivative = 1.34 \[ \int (a+b \sec (c+d x))^2 \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=\frac {12 \, A a^{2} d x \cos \left (d x + c\right )^{3} + 3 \, {\left (2 \, B a^{2} + 2 \, {\left (2 \, A + C\right )} a b + B b^{2}\right )} \cos \left (d x + c\right )^{3} \log \left (\sin \left (d x + c\right ) + 1\right ) - 3 \, {\left (2 \, B a^{2} + 2 \, {\left (2 \, A + C\right )} a b + B b^{2}\right )} \cos \left (d x + c\right )^{3} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (2 \, C b^{2} + 2 \, {\left (3 \, C a^{2} + 6 \, B a b + {\left (3 \, A + 2 \, C\right )} b^{2}\right )} \cos \left (d x + c\right )^{2} + 3 \, {\left (2 \, C a b + B b^{2}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{12 \, d \cos \left (d x + c\right )^{3}} \]

input
integrate((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)+C*sec(d*x+c)^2),x, algorithm= 
"fricas")
 
output
1/12*(12*A*a^2*d*x*cos(d*x + c)^3 + 3*(2*B*a^2 + 2*(2*A + C)*a*b + B*b^2)* 
cos(d*x + c)^3*log(sin(d*x + c) + 1) - 3*(2*B*a^2 + 2*(2*A + C)*a*b + B*b^ 
2)*cos(d*x + c)^3*log(-sin(d*x + c) + 1) + 2*(2*C*b^2 + 2*(3*C*a^2 + 6*B*a 
*b + (3*A + 2*C)*b^2)*cos(d*x + c)^2 + 3*(2*C*a*b + B*b^2)*cos(d*x + c))*s 
in(d*x + c))/(d*cos(d*x + c)^3)
 
3.9.72.6 Sympy [F]

\[ \int (a+b \sec (c+d x))^2 \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=\int \left (a + b \sec {\left (c + d x \right )}\right )^{2} \left (A + B \sec {\left (c + d x \right )} + C \sec ^{2}{\left (c + d x \right )}\right )\, dx \]

input
integrate((a+b*sec(d*x+c))**2*(A+B*sec(d*x+c)+C*sec(d*x+c)**2),x)
 
output
Integral((a + b*sec(c + d*x))**2*(A + B*sec(c + d*x) + C*sec(c + d*x)**2), 
 x)
 
3.9.72.7 Maxima [A] (verification not implemented)

Time = 0.23 (sec) , antiderivative size = 207, normalized size of antiderivative = 1.54 \[ \int (a+b \sec (c+d x))^2 \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=\frac {12 \, {\left (d x + c\right )} A a^{2} + 4 \, {\left (\tan \left (d x + c\right )^{3} + 3 \, \tan \left (d x + c\right )\right )} C b^{2} - 6 \, C a b {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} - 3 \, B b^{2} {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 12 \, B a^{2} \log \left (\sec \left (d x + c\right ) + \tan \left (d x + c\right )\right ) + 24 \, A a b \log \left (\sec \left (d x + c\right ) + \tan \left (d x + c\right )\right ) + 12 \, C a^{2} \tan \left (d x + c\right ) + 24 \, B a b \tan \left (d x + c\right ) + 12 \, A b^{2} \tan \left (d x + c\right )}{12 \, d} \]

input
integrate((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)+C*sec(d*x+c)^2),x, algorithm= 
"maxima")
 
output
1/12*(12*(d*x + c)*A*a^2 + 4*(tan(d*x + c)^3 + 3*tan(d*x + c))*C*b^2 - 6*C 
*a*b*(2*sin(d*x + c)/(sin(d*x + c)^2 - 1) - log(sin(d*x + c) + 1) + log(si 
n(d*x + c) - 1)) - 3*B*b^2*(2*sin(d*x + c)/(sin(d*x + c)^2 - 1) - log(sin( 
d*x + c) + 1) + log(sin(d*x + c) - 1)) + 12*B*a^2*log(sec(d*x + c) + tan(d 
*x + c)) + 24*A*a*b*log(sec(d*x + c) + tan(d*x + c)) + 12*C*a^2*tan(d*x + 
c) + 24*B*a*b*tan(d*x + c) + 12*A*b^2*tan(d*x + c))/d
 
3.9.72.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 364 vs. \(2 (126) = 252\).

Time = 0.33 (sec) , antiderivative size = 364, normalized size of antiderivative = 2.72 \[ \int (a+b \sec (c+d x))^2 \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=\frac {6 \, {\left (d x + c\right )} A a^{2} + 3 \, {\left (2 \, B a^{2} + 4 \, A a b + 2 \, C a b + B b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - 3 \, {\left (2 \, B a^{2} + 4 \, A a b + 2 \, C a b + B b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) - \frac {2 \, {\left (6 \, C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 12 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 6 \, C a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 6 \, A b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 3 \, B b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 6 \, C b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 12 \, C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 24 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 12 \, A b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 4 \, C b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 6 \, C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 12 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 6 \, C a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 6 \, A b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 3 \, B b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 6 \, C b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{3}}}{6 \, d} \]

input
integrate((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)+C*sec(d*x+c)^2),x, algorithm= 
"giac")
 
output
1/6*(6*(d*x + c)*A*a^2 + 3*(2*B*a^2 + 4*A*a*b + 2*C*a*b + B*b^2)*log(abs(t 
an(1/2*d*x + 1/2*c) + 1)) - 3*(2*B*a^2 + 4*A*a*b + 2*C*a*b + B*b^2)*log(ab 
s(tan(1/2*d*x + 1/2*c) - 1)) - 2*(6*C*a^2*tan(1/2*d*x + 1/2*c)^5 + 12*B*a* 
b*tan(1/2*d*x + 1/2*c)^5 - 6*C*a*b*tan(1/2*d*x + 1/2*c)^5 + 6*A*b^2*tan(1/ 
2*d*x + 1/2*c)^5 - 3*B*b^2*tan(1/2*d*x + 1/2*c)^5 + 6*C*b^2*tan(1/2*d*x + 
1/2*c)^5 - 12*C*a^2*tan(1/2*d*x + 1/2*c)^3 - 24*B*a*b*tan(1/2*d*x + 1/2*c) 
^3 - 12*A*b^2*tan(1/2*d*x + 1/2*c)^3 - 4*C*b^2*tan(1/2*d*x + 1/2*c)^3 + 6* 
C*a^2*tan(1/2*d*x + 1/2*c) + 12*B*a*b*tan(1/2*d*x + 1/2*c) + 6*C*a*b*tan(1 
/2*d*x + 1/2*c) + 6*A*b^2*tan(1/2*d*x + 1/2*c) + 3*B*b^2*tan(1/2*d*x + 1/2 
*c) + 6*C*b^2*tan(1/2*d*x + 1/2*c))/(tan(1/2*d*x + 1/2*c)^2 - 1)^3)/d
 
3.9.72.9 Mupad [B] (verification not implemented)

Time = 18.16 (sec) , antiderivative size = 512, normalized size of antiderivative = 3.82 \[ \int (a+b \sec (c+d x))^2 \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=\frac {\frac {A\,b^2\,\sin \left (3\,c+3\,d\,x\right )}{4}+\frac {B\,b^2\,\sin \left (2\,c+2\,d\,x\right )}{4}+\frac {C\,a^2\,\sin \left (3\,c+3\,d\,x\right )}{4}+\frac {C\,b^2\,\sin \left (3\,c+3\,d\,x\right )}{6}+\frac {A\,b^2\,\sin \left (c+d\,x\right )}{4}+\frac {C\,a^2\,\sin \left (c+d\,x\right )}{4}+\frac {C\,b^2\,\sin \left (c+d\,x\right )}{2}+\frac {B\,a\,b\,\sin \left (3\,c+3\,d\,x\right )}{2}+\frac {C\,a\,b\,\sin \left (2\,c+2\,d\,x\right )}{2}+\frac {3\,A\,a^2\,\cos \left (c+d\,x\right )\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{2}+\frac {3\,B\,a^2\,\cos \left (c+d\,x\right )\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{2}+\frac {3\,B\,b^2\,\cos \left (c+d\,x\right )\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{4}+\frac {A\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )}{2}+\frac {B\,a^2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )}{2}+\frac {B\,b^2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )}{4}+\frac {B\,a\,b\,\sin \left (c+d\,x\right )}{2}+3\,A\,a\,b\,\cos \left (c+d\,x\right )\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )+\frac {3\,C\,a\,b\,\cos \left (c+d\,x\right )\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{2}+A\,a\,b\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )+\frac {C\,a\,b\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )}{2}}{d\,\left (\frac {3\,\cos \left (c+d\,x\right )}{4}+\frac {\cos \left (3\,c+3\,d\,x\right )}{4}\right )} \]

input
int((a + b/cos(c + d*x))^2*(A + B/cos(c + d*x) + C/cos(c + d*x)^2),x)
 
output
((A*b^2*sin(3*c + 3*d*x))/4 + (B*b^2*sin(2*c + 2*d*x))/4 + (C*a^2*sin(3*c 
+ 3*d*x))/4 + (C*b^2*sin(3*c + 3*d*x))/6 + (A*b^2*sin(c + d*x))/4 + (C*a^2 
*sin(c + d*x))/4 + (C*b^2*sin(c + d*x))/2 + (B*a*b*sin(3*c + 3*d*x))/2 + ( 
C*a*b*sin(2*c + 2*d*x))/2 + (3*A*a^2*cos(c + d*x)*atan(sin(c/2 + (d*x)/2)/ 
cos(c/2 + (d*x)/2)))/2 + (3*B*a^2*cos(c + d*x)*atanh(sin(c/2 + (d*x)/2)/co 
s(c/2 + (d*x)/2)))/2 + (3*B*b^2*cos(c + d*x)*atanh(sin(c/2 + (d*x)/2)/cos( 
c/2 + (d*x)/2)))/4 + (A*a^2*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2))*co 
s(3*c + 3*d*x))/2 + (B*a^2*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2))*co 
s(3*c + 3*d*x))/2 + (B*b^2*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2))*co 
s(3*c + 3*d*x))/4 + (B*a*b*sin(c + d*x))/2 + 3*A*a*b*cos(c + d*x)*atanh(si 
n(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)) + (3*C*a*b*cos(c + d*x)*atanh(sin(c/2 
 + (d*x)/2)/cos(c/2 + (d*x)/2)))/2 + A*a*b*atanh(sin(c/2 + (d*x)/2)/cos(c/ 
2 + (d*x)/2))*cos(3*c + 3*d*x) + (C*a*b*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + 
 (d*x)/2))*cos(3*c + 3*d*x))/2)/(d*((3*cos(c + d*x))/4 + cos(3*c + 3*d*x)/ 
4))